---
title: Number Field
description: A numeric input element with increment and decrement buttons, and a scrub area.

links:
  doc: https://base-ui.com/react/components/number-field#api-reference
---

<ComponentPreview name="p-number-field-1" />

## Installation

<CodeTabs>

<TabsList>
  <TabsTab value="cli">CLI</TabsTab>
  <TabsTab value="manual">Manual</TabsTab>
</TabsList>
<TabsPanel value="cli">

```bash
npx shadcn@latest add @coss/number-field
```

</TabsPanel>

<TabsPanel value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
npm install @base-ui-components/react
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource
  name="number-field"
  title="components/ui/number-field.tsx"
/>

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsPanel>

</CodeTabs>

## Usage

```tsx
import {
  NumberField,
  NumberFieldDecrement,
  NumberFieldGroup,
  NumberFieldIncrement,
  NumberFieldInput,
  NumberFieldScrubArea,
} from "@/components/ui/number-field"
```

```tsx
<NumberField defaultValue={0}>
  <NumberFieldScrubArea label="Quantity" />
  <NumberFieldGroup>
    <NumberFieldDecrement />
    <NumberFieldInput />
    <NumberFieldIncrement />
  </NumberFieldGroup>
</NumberField>
```

## Examples

For accessible labelling and validation, prefer using the `Field` component to wrap number fields. See the related example: [Number field](/ui/docs/components/field#number-field).

### Small Size

<ComponentPreview name="p-number-field-2" />

### Large Size

<ComponentPreview name="p-number-field-3" />

### Disabled

<ComponentPreview name="p-number-field-4" />

### With External Label

<ComponentPreview name="p-number-field-5" />

### With Scrub

<ComponentPreview name="p-number-field-6" />

### With Range

<ComponentPreview name="p-number-field-7" />

### With Formatted Value

<ComponentPreview name="p-number-field-8" />

### With Step

<ComponentPreview name="p-number-field-9" />

### Form Integration

<ComponentPreview name="p-number-field-10" />
